package com.String;

public class MainString {
    public static void main(String[] args) {

        compareTo();
        stringLen();
        stringSub();
        startWith();
    }

    private static void startWith() {
        String[] starts = new String[]{"HuNNU71240597", "HaNNU71240597", "71240597"};
        System.out.println(starts.length);
        for (String start : starts) {
            System.out.println("HuNNU开头？" + start.startsWith("HuNNU"));
        }
    }

    private static void compareTo() {
        System.out.println("字符串比大小：");
        System.out.println("1456".compareTo("1234"));
    }

    private static void stringLen() {
        String data = "2021";
        System.out.println(data + " 长度: " + data.length());
        data = "2021年";
        System.out.println(data + " 长度: " + data.length());
    }

    private static void stringSub() {
        stringSub("总共5条");
        stringSub("总共51条");
    }

    private static void stringSub(String data) {
        String rel = data.substring(2).equals("5条") ? "true" : "false";
        System.out.println(data + " is " + rel);
    }
}